'use strict';
//
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	//获取数据库的对象
	const db = uniCloud.database();
	//获取表的对象
	const tb = db.collection("idea");
	//一个给对象设置值的对象 用于修改
	const dbCmd =db.command;
	//根据类型进行操作
	switch (event.type) {
		//添加一条idea记录
		case 'addIdea': {
				let {user_id,context}=event;
				//查找
				let addResult = await tb.add({
					user_id:user_id,
					context:context
				})
				
				return {state:200,data:addResult};
		};
	}
};
